/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.schedule.core.repository.entity;

import com.gitee.peigenlpy.actable.annotation.Column;
import com.gitee.peigenlpy.actable.annotation.Index;
import com.gitee.peigenlpy.actable.annotation.Table;
import com.gitee.peigenlpy.actable.annotation.Unique;
import com.gitee.peigenlpy.actable.constants.MySqlCharsetConstant;
import com.gitee.peigenlpy.actable.constants.MySqlEngineConstant;
import com.gitee.peigenlpy.actable.constants.MySqlTypeConstant;
import info.peigen.hotpot.common.core.enums.YesOrNo;
import info.peigen.hotpot.component.data.repository.beetlsql.entity.AbstractCreateTimeEntity;
import info.peigen.hotpot.component.schedule.facade.enums.ScheduleCommunicationMethod;
import info.peigen.hotpot.component.schedule.facade.enums.ScheduleExecuteResultCode;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

import java.util.Date;

/**
 * <b>(ScheduleJobEntity)</b>
 * 定时任务Job表
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/12/29
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
@Table(name = "schedule_job", comment = "定时任务Job表", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
@org.beetl.sql.annotation.entity.Table(name = "schedule_job")
public class ScheduleJobEntity extends AbstractCreateTimeEntity {
    @Column(name = "job_name", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "任务名")
    @Unique(value = "jobName", columns = "job_name")
    @org.beetl.sql.annotation.entity.Column("job_name")
    String                      jobName;
    @Column(name = "cron", type = MySqlTypeConstant.VARCHAR, length = 20, isNull = false, comment = "cron")
    @org.beetl.sql.annotation.entity.Column("cron")
    String                      cron;
    @Column(name = "yesOrNo", type = MySqlTypeConstant.VARCHAR, length = 3, isNull = false, defaultValue = "'Y'", comment = "是否可用")
    @Index(value = "yesOrNo", columns = "yesOrNo")
    @org.beetl.sql.annotation.entity.Column("yesOrNo")
    @Builder.Default
    YesOrNo                     yesOrNo = YesOrNo.Y;
    @Column(name = "communication_method", type = MySqlTypeConstant.VARCHAR, length = 20, isNull = false, comment = "通讯方式")
    @org.beetl.sql.annotation.entity.Column("communication_method")
    ScheduleCommunicationMethod communicationMethod;
    @Column(name = "url", type = MySqlTypeConstant.VARCHAR, length = 100, comment = "url配置")
    @org.beetl.sql.annotation.entity.Column("url")
    String                      url;
    @Column(name = "end_point", type = MySqlTypeConstant.VARCHAR, length = 20, comment = "endPoint配置")
    @org.beetl.sql.annotation.entity.Column("end_point")
    String                      endPoint;
    @Column(name = "pre_execute_time", type = MySqlTypeConstant.TIMESTAMP, comment = "上次执行时间")
    @org.beetl.sql.annotation.entity.Column(value = "pre_execute_time")
    Date                        preExecuteTime;
    @Column(name = "pre_execute_result_code", type = MySqlTypeConstant.VARCHAR, length = 20, comment = "上次执行结果")
    @org.beetl.sql.annotation.entity.Column("pre_execute_result_code")
    ScheduleExecuteResultCode   preExecuteResultCode;
    @Column(name = "next_execute_time", type = MySqlTypeConstant.TIMESTAMP, comment = "下次执行时间")
    @org.beetl.sql.annotation.entity.Column(value = "next_execute_time")
    Date                        nextExecuteTime;
    @Column(name = "execute_timeout", type = MySqlTypeConstant.INT, comment = "任务执行超时时间，单位秒")
    @org.beetl.sql.annotation.entity.Column("execute_timeout")
    Integer                     executeTimeout;
    @Column(name = "execute_fail_retry_count", type = MySqlTypeConstant.INT, comment = "失败重试次数")
    @org.beetl.sql.annotation.entity.Column("execute_fail_retry_count")
    Integer                     executeFailRetryCount;
    @Column(name = "memo", type = MySqlTypeConstant.VARCHAR, length = 200, comment = "备注")
    @org.beetl.sql.annotation.entity.Column("memo")
    String                      memo;
}